package excelExport;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.IOException;

/**
 * TODO 添加类的描述
 *
 * @author zd
 * @version 1.0, 2023/7/31 16:34
 */
public class demo {
    public static void main(String[] args) throws IOException, InvalidFormatException {
        File file = new File("D:\\userStudy.xlsx");
        XSSFWorkbook workbook = new XSSFWorkbook(file);
        XSSFSheet sheet = workbook.getSheetAt(0);
        //总列数
        int coloumNum = sheet.getRow(0).getPhysicalNumberOfCells();
        System.out.println(coloumNum);
        //总行数
        int physicalNumberOfRows = sheet.getPhysicalNumberOfRows();
        System.out.println(physicalNumberOfRows);
        String[] titles = {"name", "loginId", "courseName", "class", "trainLevelName", "category", "type", "teacherName", "teacherStaffId", "trainType", "trainCategory", "trainMethod", "startTime", "endTime", "hour", "score", "examScore", "incentiveRecord", "isPass", "certificateName", "cNum", "free", "address"};
        XSSFRow row;
        XSSFCell cell;
        for (int j = 0; j < physicalNumberOfRows; j++) {
            row = sheet.getRow(j);
            if (j == 0) {
                for (int c = 0; c < coloumNum; c++) {
                    cell = null == row.getCell(c) ? row.createCell(c) : row.getCell(c);
                }
                continue;
            }
            boolean flag = null != row && null != row.getCell(0) && StringUtils.isBlank(row.getCell(0).toString().trim());
            if (row == null || j == 1 || j == 2 || flag) {
                continue;//过滤空行
            }
            boolean exp = false;
            boolean exp1 = false;
            String cellValue0 = "";//姓名
            String cellValue1 = "";//账号
            String cellValue2 = "";//课程名称
        }
    }
}
